package com.blackcat.recode.controller;


import com.blackcat.recode.common.annotation.Log;
import com.blackcat.recode.common.result.AjaxResult;
import com.blackcat.recode.entity.Customer;
import com.blackcat.recode.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


import com.blackcat.recode.service.WorkerService;
import com.blackcat.recode.entity.Worker;

/**
 * <p> 运维人员表 前端控制器
 * @author blackcat 2024-09-13
 */
@RestController
@RequestMapping("/worker")
public class WorkerController {

    @Autowired
    private WorkerService workerService;

    @GetMapping("/getList")
    public AjaxResult getList(Integer page, Integer size, String workerName, String workerType) {
        return workerService.getList(page, size, workerName,workerType);
    }

    @Log(title = "人员编辑", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody Worker worker) {
        return workerService.edit(worker);
    }

    @GetMapping("/getOne")
    public AjaxResult getOne(String id) {
        return AjaxResult.success(workerService.getById(id));
    }

    @Log(title = "人员删除", businessType = BusinessType.DELETE)
    @DeleteMapping("/delete")
    public AjaxResult delete(String id) {
        workerService.removeById(id);
        return AjaxResult.success();
    }

    @GetMapping("/getWorkerNameList")
    public AjaxResult getWorkerNameList() {
        return workerService.getWorkerNameList();
    }
}
